//
//  WaveEffect.hpp
//  client
//
//  Created by will on 18/07/2017.
//
//

#ifndef WaveEffect_hpp
#define WaveEffect_hpp

#include "LineEffect.hpp"

using namespace cocos2d;

class WaveEffect : public LineEffect{
public:
    static WaveEffect* create(const std::string& imageFile,const std::vector<float>& waves);
public:
    WaveEffect();
    ~WaveEffect();

protected:
    virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
    
    bool initWithFile(const std::string& filename) override;
    
    void setWaves(const std::vector<float>& waves);
    
    virtual void updateLinkPos() override;
private:
    void buildVertices(const std::vector<float>& waves);
    void updateVertices();
    void onDraw(const Mat4 &transform, uint32_t flags);
private:
    
    unsigned int _nuPoints;
    std::vector<float> _waves;
    
    // Opengl
    Vec2* _vertices;
    GLubyte* _colorPointer;
    Tex2F* _texCoords;
    
    CustomCommand _customCommand;
    
    bool _dirty;
};

#endif /* WaveEffect_hpp */
